`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    18:43:31 03/20/2014 
// Design Name: 
// Module Name:    Omega_3x8 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module Omega_3x8_enc(
    input [127:0] data_in,
    output [127:0] data_out,
	 input [23:0] sel
);
	 
	 wire [127:0] stage01, stage12;
	 
	SBox_enc s0_0(.data_in1(data_in[7:0]),		.data_in2(data_in[15:8]),		.data_out1(stage01[7:0]),			.data_out2(stage01[15:8]),			.sel(sel[0]));
	SBox_enc s0_1(.data_in1(data_in[23:16]),	.data_in2(data_in[31:24]),		.data_out1(stage01[23:16]),		.data_out2(stage01[31:24]),		.sel(sel[1]));
	SBox_enc s0_2(.data_in1(data_in[39:32]),	.data_in2(data_in[47:40]),		.data_out1(stage01[39:32]),		.data_out2(stage01[47:40]),		.sel(sel[2]));
	SBox_enc s0_3(.data_in1(data_in[55:48]),	.data_in2(data_in[63:56]),		.data_out1(stage01[55:48]),		.data_out2(stage01[63:56]),		.sel(sel[3]));
	SBox_enc s0_4(.data_in1(data_in[71:64]),	.data_in2(data_in[79:72]),		.data_out1(stage01[71:64]),		.data_out2(stage01[79:72]),		.sel(sel[4]));
	SBox_enc s0_5(.data_in1(data_in[87:80]),	.data_in2(data_in[95:88]),		.data_out1(stage01[87:80]),		.data_out2(stage01[95:88]),		.sel(sel[5]));
	SBox_enc s0_6(.data_in1(data_in[103:96]),	.data_in2(data_in[111:104]),	.data_out1(stage01[103:96]),		.data_out2(stage01[111:104]),		.sel(sel[6]));
	SBox_enc s0_7(.data_in1(data_in[119:112]),	.data_in2(data_in[127:120]),	.data_out1(stage01[119:112]),		.data_out2(stage01[127:120]),		.sel(sel[7]));

	SBox_enc s1_0(.data_in1(stage01[7:0]),		.data_in2(stage01[71:64]),		.data_out1(stage12[7:0]),			.data_out2(stage12[15:8]),			.sel(sel[8]));
	SBox_enc s1_1(.data_in1(stage01[15:8]),		.data_in2(stage01[79:72]),		.data_out1(stage12[23:16]),		.data_out2(stage12[31:24]),		.sel(sel[9]));
	SBox_enc s1_2(.data_in1(stage01[23:16]),	.data_in2(stage01[87:80]),		.data_out1(stage12[39:32]),		.data_out2(stage12[47:40]),		.sel(sel[10]));
	SBox_enc s1_3(.data_in1(stage01[31:24]),	.data_in2(stage01[95:88]),		.data_out1(stage12[55:48]),		.data_out2(stage12[63:56]),		.sel(sel[11]));
	SBox_enc s1_4(.data_in1(stage01[39:32]),	.data_in2(stage01[103:96]),	.data_out1(stage12[71:64]),		.data_out2(stage12[79:72]),		.sel(sel[12]));
	SBox_enc s1_5(.data_in1(stage01[47:40]),	.data_in2(stage01[111:104]),	.data_out1(stage12[87:80]),		.data_out2(stage12[95:88]),		.sel(sel[13]));
	SBox_enc s1_6(.data_in1(stage01[55:48]),	.data_in2(stage01[119:112]),	.data_out1(stage12[103:96]),		.data_out2(stage12[111:104]),		.sel(sel[14]));
	SBox_enc s1_7(.data_in1(stage01[63:56]),	.data_in2(stage01[127:120]),	.data_out1(stage12[119:112]),		.data_out2(stage12[127:120]),		.sel(sel[15]));

	SBox_enc s2_0(.data_in1(stage12[7:0]),		.data_in2(stage12[71:64]),		.data_out1(data_out[7:0]),			.data_out2(data_out[15:8]),		.sel(sel[16]));
	SBox_enc s2_1(.data_in1(stage12[15:8]),		.data_in2(stage12[79:72]),		.data_out1(data_out[23:16]),		.data_out2(data_out[31:24]),		.sel(sel[17]));
	SBox_enc s2_2(.data_in1(stage12[23:16]),	.data_in2(stage12[87:80]),		.data_out1(data_out[39:32]),		.data_out2(data_out[47:40]),		.sel(sel[18]));
	SBox_enc s2_3(.data_in1(stage12[31:24]),	.data_in2(stage12[95:88]),		.data_out1(data_out[55:48]),		.data_out2(data_out[63:56]),		.sel(sel[19]));
	SBox_enc s2_4(.data_in1(stage12[39:32]),	.data_in2(stage12[103:96]),	.data_out1(data_out[71:64]),		.data_out2(data_out[79:72]),		.sel(sel[20]));
	SBox_enc s2_5(.data_in1(stage12[47:40]),	.data_in2(stage12[111:104]),	.data_out1(data_out[87:80]),		.data_out2(data_out[95:88]),		.sel(sel[21]));
	SBox_enc s2_6(.data_in1(stage12[55:48]),	.data_in2(stage12[119:112]),	.data_out1(data_out[103:96]),		.data_out2(data_out[111:104]),	.sel(sel[22]));
	SBox_enc s2_7(.data_in1(stage12[63:56]),	.data_in2(stage12[127:120]),	.data_out1(data_out[119:112]),	.data_out2(data_out[127:120]),	.sel(sel[23]));

endmodule
